<?php
	require_once ("db_connection.php");
	session_start();
	$pic = $_SESSION['varname'];
	$file = $_SESSION['varname1'];
	$date = date("Y-m-d H:i:s");
	$id = "ve-" . uniqid();
	$affiliateid = $_POST['affiliateid'];
	$contacts = '';
	
	for($i=0;$i<count($_POST["contactno"]);$i++)
	{	
		$contacts = $contacts . $_POST["contactno"][$i] . ',';
	}


	$query = "INSERT INTO drivers(driverid,affiliateid,driversname,contactno,image, file, remarks)
		VALUES('$id', '$affiliateid', '$_POST[name]', '$contacts','$pic', '$file', '$_POST[remarks]')";

		
	//$query1 = "INSERT INTO affile(fileid,affiliateid,filepath, date)
	///	VALUES('$id','$affiliateid','$file', '$date')";
	
	if(!mysql_query($query, $con)){
		die('Error: '. mysql_error());
	}
	//if(!mysql_query($query1, $con)){
	//	die('Error: '. mysql_error());
	//}
	
	echo "Saved!";
	
	mysql_close($con);
?>